﻿using System.Data;
using Entity;

namespace BUS
{
    public class ServiceTypeBus
    {
        public DataTable GetAllServiceType()
        {
            return CatalogueBase.GetData(ServiceTypeEnt.STORE_SELECT_ALL, new string[]{}, new object[]{}).Tables[0];
        }

        public string InsertServiceType(ServiceType svType)
        {
            var arg = new[] { ServiceTypeEnt.FIELD_SERVICETYPE_CODE, ServiceTypeEnt.FIELD_SERVICETYPE_NAME };
            var obj = new object[] { svType.ServiceTypeCode, svType.ServiceTypeName };

            return CatalogueBase.SaveData(ServiceTypeEnt.STORE_INSERT, arg, obj);
        }

        public string UpdateServiceType(ServiceType svType)
        {
            var arg = new[] { ServiceTypeEnt.FIELD_SERVICETYPE_ID, ServiceTypeEnt.FIELD_SERVICETYPE_CODE, ServiceTypeEnt.FIELD_SERVICETYPE_NAME };
            var obj = new object[] { svType.ServiceTypeID, svType.ServiceTypeCode, svType.ServiceTypeName };

            return CatalogueBase.SaveData(ServiceTypeEnt.STORE_UPDATE, arg, obj);
        }

        public DataTable GetServiceTypeByCode(string code)
        {
            return CatalogueBase.GetData(ServiceTypeEnt.STORE_SELECT_BY_CODE, new[] { ServiceTypeEnt.FIELD_SERVICETYPE_CODE }, new object[] { code }).Tables[0];
        }

        public string DeleteServiceType(int id)
        {
            return CatalogueBase.DeleteData(ServiceTypeEnt.STORE_DELETE, new[] { ServiceTypeEnt.FIELD_SERVICETYPE_ID }, new object[] { id });
        }

        public DataTable GetServiceTypeById(int id)
        {
            return CatalogueBase.GetData(ServiceTypeEnt.STORE_SELECT_BY_ID, new[] { ServiceTypeEnt.FIELD_SERVICETYPE_ID }, new object[] { id }).Tables[0];
        }
    }
}
